<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ include file="../common/taglibs.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<title>终端信息下载</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<!-- 当前页面样式 -->
<link rel="stylesheet" href="<s:url value="/css/common.css"/>" />
<!-- 当前页面样式 END -->
<script type="text/javascript"
	src="<c:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
<script language="javascript" type="text/javascript"
	src="<c:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
<script type='text/javascript' src='<s:url value="/dwr/engine.js"/>'></script>
<script type='text/javascript'
	src='<s:url value="/dwr/interface/MccQuery.js"/>'></script>

<script type="text/javascript">
	$(function(){
		$('#sub').click(function(){
			var mid=$('#mid').val();
			if(mid.trim().length<=0){
				if(!checkRange('query')){
					return;
				}
			}
			$(this).attr("disabled",true);
			$("#download").attr("action","<%=basePath%>/terminalDownload/termList.ct");
			$("#download").submit();
		});
		
		function checkRange(type){
			var beginTime = $("#start").val();
			var endTime = $("#end").val();
			if(beginTime.length<=0){
				alert('起始时间不能为空!');
				return false;
			}
			if(endTime.length<=0){
				alert('结束时间不能为空!');
				return false;
			}			
			if(type=='stock'){
				if(endTime>='20170701'){
					alert('存量终端的结束时间必须小于20170701');
					return false;
				}
			}
			if(type=='added'){
				if(beginTime<'20170701'){
					alert('新增终端的开始时间必须大于或等于20170701');
					return false;
				}
			}
			if(endTime<beginTime){
				alert('结束时间必须大于或等于起始时间!');
				return false;
			}
			return true;
		}
		
		$('#cdw').click(function(){
			var mid=$('#mid').val();
			if(mid.trim().length<=0){
				if(!checkRange('stock')){
					return;
				}
			}
			$('#target').val('downloadStock');
			$("#download").attr("action","<%=basePath%>/terminalDownload/download.ct");
			$("#download").submit();
		});
		$('#xdw').click(function(){
			var mid=$('#mid').val();
			if(mid.trim().length<=0){
				if(!checkRange('added')){
					return;
				}
			}
			$('#target').val('downloadAdded');
			$("#download").attr("action","<%=basePath%>/terminalDownload/download.ct");
			$("#download").submit();
		});
		
	})
</script>



</head>

<body>
<table class="tb">
    <tbody>
	<s:form id="download" action="" method="post"
		theme="simple" enctype="multipart/form-data">
		<s:hidden name="searchCondition.flag" id="target"></s:hidden>
		<table class="tb">
			<tbody>
				<tr class="tb-line">
					<td class="tb-td" colspan="4"><div class="tb-h2">POS收单运营管理平台</div></td>
				</tr>

				<tr class="tb-line">
					<td class="tb-td" colspan="4"><div class="tb-h3">终端信息下载</div></td>
				</tr>
				 <tr class="tb-line">
				 	<td width="12%" style="min-width: 150px" align="right" class="tb-td">
				 	 <div class="tb-h4">商户号：</div>
				 	 </td>
					<td class="tb-td">
					<label class="tb-input-normal">
							<s:textfield id="mid"
							name="searchCondition.mchtCd" cssClass="queryWidth" />
							</label>
					</td>
					<td width="12%" style="min-width: 150px" align="right" class="tb-td">
	                <div class="tb-h4">日期：</div></td>
	            <td class="tb-td">
	                <label class="tb-input-mini">
	                	<s:textfield id="start" name="searchCondition.start" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
							theme="simple" cssClass="queryWidth" /> 
					</label>-
					<label class="tb-input-mini">
						<s:textfield id="end" name="searchCondition.end" onFocus="WdatePicker({dateFmt:'yyyyMMdd',readOnly:true,wdate:true,errDealMode:0});"
							theme="simple" cssClass="queryWidth" />
					</label>
					<code class="asterisk">*</code>
				</td>	
				</tr>
				<tr>
					<td colspan="4" align="center"><span style="font-color: red"><s:actionerror /></span>
							<span style="color: red;"><s:actionmessage /></span > <span style="font-color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
					</td>
				</tr>
				<tr class="tb-line">
            	<td class="tb-td line-submit" align="right" colspan="4">
                <label class="tb-input-submit"><input type="button" value="查   询" id="sub"/></label>
				<label class="tb-input-submit"><s:reset value="取  消" /></label>
				<!-- <label class="tb-input-submit"><input type="button" value="存量终端信息下载" id="cdw"/></label> -->
				<label class="tb-input-submit"><input type="button" value="新增终端信息下载" id="xdw"/></label></td>
				</tr>
				
				<s:if
					test="#request.searchRsList != null && #request.searchRsList.size>0">
					<tr class="tb-line">
						<td class="tb-td paging" colspan="4"><page:pageCount
								max_pages="11" totalPage="${requestScope.totalPage}"
								currentPage="${requestScope.currentPage}"
								action="${rootPath}/terminalDownload/termList.ct?currentPage=" />

						</td>
					</tr>
				</s:if>
			</tbody>
		</table>
</s:form>
</tbody>
</table>	
	
	<div class="big-tb">
			<table class="tb" style="width: 100%;">
				<thead>
            	<tr class="tb-line">
                <th class="tb-th" colspan="7"><div class="tb-h3">终端基本信息列表</div></th>
            	</tr>            	
					<tr class="tb-line bg-gray">
						<th class="tb-th">商户号</th>
						<th class="tb-th">终端号</th>
						<th class="tb-th">终端品牌</th>
						<th class="tb-th">终端机型</th>
						<th class="tb-th">终端类型</th>
						<th class="tb-th">序列号</th>
						<th class="tb-th">日期</th>
					</tr>
					</thead>
				<tbody>
					<s:iterator value="#request.searchRsList" status="stat" id="term">
						<tr class="tb-line">
						<td class="tb-td" align="center">
							 <s:property value="#term.mchtCd"/>
						</td>
						<td class="tb-td" align="center">
							 <s:property value="#term.termId"/>
						</td>
						<td class="tb-td" align="center">
							 <s:property value="#term.brand"/>
						</td>
						<td class="tb-td" align="center">
							 <s:property value="#term.model"/>
						</td>
						<td class="tb-td" align="center">
							 <s:property value="#term.type"/>
						</td>
						<td class="tb-td" align="center">
							 <s:property value="#term.deviceCd"/>
						</td>
						<td class="tb-td" align="center">
							 <s:property value="#term.date"/>
						</td>
						</tr>
					</s:iterator>
				</tbody>
				</table>
				</div>
				
</body>
</html>